﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Globalization;

namespace TelecoSystems.Infrastructure.Helpers
{
	public class EmailConverter : IValueConverter
	{
		//[ValueConversion(typeof(String), typeof(String))]
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  		{
    		string res = "mailto:" + (string)value;
			return res;
 	 	}	
		
		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return value;	
		}
	}
	
	public class DetailVisibilityConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  		{
    		return ((int)value > -1) ? Visibility.Visible : Visibility.Collapsed;	
		}	
		
		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return value;	
		}
	}
	
	public class ListboxMarginConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  		{
			Thickness mSel = new Thickness(15, 40, 15, 270);
			Thickness mUnSel = new Thickness(15, 40, 15, 10);
			return ((int)value > -1) ? mSel : mUnSel;	
		}	
		
		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return value;	
		}
	}

    public class GenderToImageConverter : IValueConverter
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string gender = "";
            if ((string)value == "M")
                gender = "male";
            else if ((string)value == "F")
                gender = "female";
                
            return string.Format("/TelecoSystems.Modules.Customers;component/Assets/Icons/{0}.png", gender);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }

    public class GenderToBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {            
           return ((string)value == (string)parameter);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((bool)value) ? (string)parameter :
                (((string)parameter == "M") ? "F" : "M");
        }
    }
}